package com.yfp.machine.controller;

import com.yfp.common.core.domain.R;
import com.yfp.common.security.annotation.InnerAuth;
import com.yfp.machine.domain.vo.CoordinateLimitSummaryVo;
import com.yfp.machine.domain.vo.CoordinateSearchLimitNameVo;
import com.yfp.machine.domain.vo.FilterDeviceInfoVo;
import com.yfp.machine.domain.vo.SearchBasicInfoVo;
import com.yfp.machine.service.AppletMachineService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 小程序设备相关接口
 *
 *
 * @date 2023/12/18
 */
@Tag(name = "小程序设备相关接口")
@RestController
@RequestMapping("rpc")
public class AppletMachineController {

    @Resource
    private AppletMachineService appletMachineService;

    @Operation(summary = "获取设备信息- 筛选设备基础数据")
    @GetMapping("device/limit/basic_info")
    @InnerAuth
    public R deviceLimitBasicInfo(
            @Valid @Parameter(name = "filterDeviceInfoVo") FilterDeviceInfoVo filterDeviceInfoVo) {
        return appletMachineService.deviceLimitBasicInfo(filterDeviceInfoVo);
    }


    @Operation(summary = "获取设备信息- 获取设备点位类型")
    @GetMapping("position/type/search/basic_info")
    @InnerAuth
    public R positionTypeSearchBasicInfo(
            @Valid @Parameter(name = "searchBasicInfoVo") SearchBasicInfoVo searchBasicInfoVo) {
        return appletMachineService.positionTypeSearchBasicInfo(searchBasicInfoVo);
    }

    @Operation(summary = "获取设备信息- 根据坐标点和距离返回设备信息")
    @GetMapping("device/coordinate/limit/summary")
    @InnerAuth
    public R deviceCoordinateLimitSummary(
            @Valid @Parameter(name = "coordinateLimitSummaryVo")
            CoordinateLimitSummaryVo coordinateLimitSummaryVo) {
        return appletMachineService.deviceCoordinateLimitSummary(coordinateLimitSummaryVo);
    }

    @Operation(summary = "获取设备信息- 根据坐标点和距离以及搜索名称返回设备信息")
    @GetMapping("/device/coordinate/search/limit/name")
    @InnerAuth
    public R deviceCoordinateSearchLimitName(
            @Valid @Parameter(name = "coordinateLimitSummaryVo")
            CoordinateSearchLimitNameVo coordinateLimitSummaryVo) {
        return appletMachineService.deviceCoordinateSearchLimitName(coordinateLimitSummaryVo);
    }

    @Operation(summary = "获取设备信息- 根据设备id获取营业时间")
    @GetMapping("/device/saleTime/getSaleTimeByMachineId")
    @InnerAuth
    public R getSaleTimeByMachineId(
            @Valid @Parameter(name = "machineId") String machineId) {
        return appletMachineService.getSaleTimeByMachineId(machineId);
    }

    @Operation(summary = "获取设备信息- 根据设备id获取设备信息")
    @GetMapping("/device/machine/getMachineById")
    @InnerAuth
    public R getMachineById(
            @Valid @Parameter(name = "machineId") String machineId) {
        return R.ok(appletMachineService.getMachineById(machineId));
    }

}
